﻿<template>
  <section>
    <div class="link-box">
      <div class="linkClass">
        <a href="javascript:void(0)"
           @click="toDetail">{{ value }}
        </a>
      </div>
      <i class="el-icon-copy-document iconClass"
         @click="copy(value)" />
      <!-- <div>
        <icon-svg icon-name="chakan"
                  class-name="iconsty pointer"
                  @click.stop="handleShow" />
      </div> -->
    </div>
    <!-- <el-dialog title="拆分运单"
               modal-append-to-body
               :visible.sync="dialogVisible"
               width="1000px">
      <div class="contSty">
        <template v-for="(item, i) in listData">
          <div :key="i"
               class="cont-bg">
            <el-row :gutter="20"
                    class="childLogo">
              <icon-svg icon-name="chaifenyundantiao"
                        class-name="icon-bg" />
              <div class="childTit">
                {{ `拆分运单${i + 1}` }} {{ item.contractNo }}
              </div>
            </el-row>
            <el-row :gutter="20"
                    class="childItem line-herger14">
              <el-col :span="10"
                      class="shipSty">
                <div class="line-herger14">
                  <icon-svg icon-name="qidian_jiedian"
                            class-name="icon-1" />
                  {{ item.customer.customerName }}<br />
                  <p class="fontSty-4">
                    发货地址：{{ item.fromAddress.province
                    }}{{ item.fromAddress.district }}{{ item.fromAddress.city
                    }}{{ item.fromAddress.address }}
                  </p>
                  <p class="fontSty-4">
                    联系方式：{{ item.fromContact.contactName }}
                    {{ item.fromContact.contactMobile }}
                  </p>
                  <p class="fontSty-4">发货时间：{{ item.fromTime }}</p>
                </div>
              </el-col>
              <el-col :span="10"
                      class="shipSty">
                <div class="line-herger14">
                  <icon-svg icon-name="zhongdian_jiedian"
                            class-name="icon-1" />
                  {{ item.consignee.consigneeName }}<br />
                  <p class="fontSty-4">
                    收货地址：{{ item.toAddress.province
                    }}{{ item.toAddress.district }}{{ item.toAddress.city
                    }}{{ item.toAddress.address }}
                  </p>
                  <p class="fontSty-4">
                    联系方式：{{ item.toContact.contactName }}
                    {{ item.toContact.contactMobile }}
                  </p>
                  <p class="fontSty-4">收货时间：{{ item.toTime }}</p>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="5"
                      class="fontSty-1">
                总数量(件)：{{ item.waybillCache.totalQuantity }}
              </el-col>
              <el-col :span="5"
                      class="fontSty-1">
                总重量(公斤)：{{ item.waybillCache.totalWeight }}
              </el-col>
              <el-col :span="5"
                      class="fontSty-1">
                总体积(方)：{{ item.waybillCache.totalVolume }}
              </el-col>
            </el-row>
          </div>
        </template>
      </div>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog> -->
  </section>
</template>

<script>
import { transport } from "@/api/index";
export default {
  name: "SplitChildOrder",
  props: {
    value: {
      type: String
    },
    row: {
      type: Object,
      default: () => { }
    },
    paramsData: {
      type: Object,
      default: () => { }
    },
    linkType: {
      type: Number,
      default: 0
    },
    //拆单、合单标记
    orderType: {
      type: Number,
      default: 0
    },
    url: [String]
  },
  data () {
    return {
      listData: [],
      page: 1,
      pageSize: 10,
      total: 0,
      dialogVisible: false
    };
  },
  mounted () {
    // window.addEventListener("scroll", this.handleScroll, true); // 监听滚动事件
  },
  destroyed () {
    // window.removeEventListener("scroll", this.handleScroll, true); //销毁监听
  },
  methods: {
    // handleScroll (e) {
    //   if (e.target && e.target._prevClass != "contSty")
    //     this.$refs.popover.doClose();
    // },
    handleShow () {
      this.getDivideWayBill();
      // if (this.dialogVisible) {
      //   this.dialogVisible = false;
      // } else {
      //   this.getDivideWayBill();
      // }
    },
    // 拆单详情
    async getDivideWayBill () {
      const { code, data } = await transport.getDivideWaybillDetail(
        this?.row?.id
      );
      if (code !== 0) return;
      console.log('data>>>>>>>', data)
      this.listData = data.childs;
      if (this.listData.length) {
        this.dialogVisible = true;
      } else {
        this.$message.error('暂无数据')
      }
    },
    toDetail () {
      if (this.linkType) {
        this.$router.push({
          name: this.url,
          query: { ...this.paramsData }
        });
      } else {
        const { href } = this.$router.resolve({
          name: this.url,
          query: { ...this.paramsData }
        });
        window.open(href, "_blank");
      }
    },
    copy (val) {
      // 模拟 输入框
      var cInput = document.createElement("input");
      cInput.value = val;
      document.body.appendChild(cInput);
      cInput.select(); // 选取文本框内容 // 执行浏览器复制命令 // 复制命令会将当前选中的内容复制到剪切板中（这里就是创建的input标签） // Input要在正常的编辑状态下原生复制方法才会生效
      document.execCommand("copy");
      this.$message({ type: "success", message: "复制成功" });
      // 复制成功后再将构造的标签 移除
      document.body.removeChild(cInput);
    }
  }
};
</script>
<style lang="scss" scoped>
.flex-code-box {
  display: flex;
}
.contSty {
  min-height: 200px;
  max-height: 408px;
  overflow-x: hidden;
}
.cont-bg {
  background: #fafafa;
  margin-top: 5px;
  margin-left: 5px;
}
.icon-bg {
  width: 210px !important;
  height: 30px;
  position: absolute;
  top: 0;
  margin: 0;
}
.childTit {
  width: 210px !important;
  height: 30px;
  position: absolute;
  left: 5px;
  top: 5px;
  margin: 0;
  color: var(--prev-bg-white);
}
.childLogo {
  height: 30px;
  margin: 0 !important;
}
.childItem {
  padding-top: 15px;
  margin-bottom: 16px !important;
}
.line-herger14 {
  line-height: 14px;
}
.iconsty {
  width: 14px;
  height: 14px;
  margin-left: 5px;
}
.icon-1 {
  width: 24px;
  height: 24px;
  position: absolute;
  left: -20px;
  top: -2px;
}
.shipSty {
  position: relative;
  padding: 0 0px;
  margin-left: 60px;
}
.link-box {
  display: flex;
  align-items: center;
}

.linkClass {
  max-width: 260px !important;
  color: var(--prev-color-primary) !important;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  // width: 100px !important;
  // color: var(--prev-color-primary) !important;
  // display: block;
  // overflow: hidden;
  // white-space: nowrap;
  // text-overflow: ellipsis;
  // text-align: center;
}
.iconClass {
  margin-left: 2px;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  color: chocolate;
}
.fontSty-4 {
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 20px;
}
</style>
